/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lolbuilder.mainClasses;

import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import lolbuilder.Items.Interf.ItemsSuper;

/**
 *
 * @author maximveron
 */
public class AllItems {
    public static ArrayList<ItemsSuper> items=new ArrayList<ItemsSuper>();

    public static void populate() {//C:\\Users\\chocoboSan\\Documents\\NetBeansProjects\\LoLBuilder\\
        File file = new File("build\\classes\\lolbuilder\\Items\\Impl");
	File[] listOfFiles = file.listFiles();
        Object locItem;
        File buildfolder=new File("build\\classes\\");
        for (File f : listOfFiles) {
            if (f.isFile()) {
                if (f.getName().split("\\.")[1].equals("java")) {
                    try {
                        // Convert File to a URL
                        URL url = buildfolder.toURL();;
                        URL[] urls = new URL[]{url};

                        // Create a new class loader with the directory
                        ClassLoader loader = new URLClassLoader(urls);

                        // Load in the class; Class.childclass should be located in
                        // the directory file:/c:/class/user/information
                        locItem=loader.loadClass("lolbuilder.Items.Impl."+f.getName().split("\\.")[0]).newInstance();
                        items.add((ItemsSuper) locItem);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
    public static void main(String[] args) {
        populate();
        System.out.println(items);
    }
}
